<template>
	<view class="content">
		<view class=" padding">
			<template v-if="stateShenHe==1">
				<!-- 审核中 -->
				<view class="aside">
					<image src="/static/image/mine/one.png" mode="widthFix"></image>
				</view>
				<view class="text text_a color_jiu nav">
					<view class="">工作人员将会在3个工作日内审核您的提交，</view>
					<view class=""> 审核通过将会给您商家端下载链接，</view>
					<view class="">如果审核未通过平台将会给您反馈~</view>
					<view class="">请留意此界面！</view>
				</view>
			</template>
			<template v-if="stateShenHe==2">
				<!-- 审核通过 -->
				<view class="aside">
					<image src="/static/image/mine/three.png" mode="widthFix"></image>
				</view>
				<view class="block2 nav ">
					<view class=" text text_a color_ling">恭喜您，您已经通过审核！</view>
				</view>
				<view class="margin_top">
					<u-parse :content="shopInfo.shop_download_intr"></u-parse>
				</view>
			</template>
			<template v-if="stateShenHe==3">
				<!-- 审核不通过 -->
				<view class="aside">
					<image src="/static/image/mine/two.png" mode="widthFix"></image>
				</view>
				<view class="block3 nav">
					<view class="text text_a color_jiu">很遗憾，您没有通过审核!</view>
					<view class="text text_a color_jiu">
						如有疑问？
						<text style="color: rgba(239, 137, 51, 1);" @click="phone(kefuPhone)">联系客服</text>
					</view>
					<view class="padding ffffff border nav">
						<view class="text color_san text_x">失败原因：{{dataAll.refuse_reason}}</view>
					</view>
				</view>
			</template>
		</view>
		<!-- <view class="gudingdb" @click="jumpurl" v-if="stateShenHe==3">
			<view class="bigbtn">重新提交</view>
		</view> -->
		<!-- 重新提交 -->
		<view class="footer ffffff padding" v-if="stateShenHe==3">
			<view class="footerButton" @click="jumpurl">重新提交</view>
		</view>
		<view class="footer ffffff padding" v-if="stateShenHe==2">
			<view class="footerButton" @click="downLoad">点击下载商家端APP</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				stateShenHe: 0, //审核状态:1=审核中,2=审核通过,3=审核未通过
				dataAll: {},
				platform: "",
				kefuPhone: "", //客户电话
				shopInfo:{}
			}
		},
		async onLoad() {
			this.getHomeInit()
			let res=await this.initApp()
			this.shopInfo=res.data
		},
		onShow() {
			this.init()
		},
		methods: {
			init() {
				httpRequest.request('/api/shop/apply_pre', 'GET', {}).then(res => {
					if (res.data.info) {
						this.stateShenHe = res.data.info.state
						this.dataAll = res.data.info
					}
				})
			},
			getHomeInit() {
				httpRequest.request("/api/index/index", "GET", {}).then(res => {
					this.kefuPhone = res.data.client_tel
				})
			},
			phone(p) {
				uni.makePhoneCall({
					phoneNumber: p.toString()
				}).catch((e) => {
					// console.log(e)  //用catch(e)来捕获错误{makePhoneCall:fail cancel}
				})
			},
			jumpurl() {
				uni.redirectTo({
					url: "/pages_mine/businessSettled"
				})
			},
			downLoad() {
				
				let _this = this
				let url = ""
				if (uni.getSystemInfoSync().platform.toLocaleLowerCase() == "android") {
					url = this.shopInfo.shop_download_adr
					
				} else {
					url = this.shopInfo.shop_download_ios;
					
					plus.runtime.launchApplication({
					    action: url
					}, function(e) {
					    uni.showToast({
					    	title: '打开appstore失败',
							icon:'none'
					    });
					});
					
					return false;
				}
				uni.showLoading({
					title:"下载中",
					mask:true
				})
				uni.downloadFile({
					// url: "https://www.wanxiangshide.xyz/app/泽麟药业.apk",
					url: url,
					success(res) {
						if (res.statusCode == 200) {
							uni.hideLoading()
							httpRequest.toast("安装包下载成功，即将安装！")
							// plus.runtime.install(res.tempFilePath)
							plus.runtime.install(res.tempFilePath, {
								force: false  
							}, function() {  
								// console.log('install success...');
								plus.runtime.restart();
							}, function(e) {  
								console.error('install fail...',e);  
								uni.showToast({
									title: '升级失败',
									icon:'none'
								});
							});  
						} else {
							uni.hideLoading()
							httpRequest.toast("安装包下载失败，请联系客服！")
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.copy {
		margin-left: 30rpx;
		color: RGBA(242, 165, 101, 1);
	}

	.nav {
		margin-top: 50rpx;
	}

	.dianhua {
		font-size: 32rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
	}

	.chengsetext {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: RGBA(242, 165, 101, 1);
	}

	.heisetext {
		font-size: 28rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #000000;
	}

	.huisetext {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}

	.aside {
		margin: 110rpx auto 0;
		width: 306rpx;
		height: 306rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.eshiliu {
		font-size: 26rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #666666;
	}

	.erwm {
		width: 243rpx;
		height: 243rpx;
		margin: 30rpx auto 0;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.neijianju {
		padding: 0 130rpx;
	}

	.tkbox {
		padding-bottom: 60rpx;
	}
</style>